<!-- 物流查询 -->
<template>
    <div class="app-container page-content-body">
        <div class="search-container">
            <el-form :class="['search-container']" :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
              <el-form-item label="快递公司" prop="type">
                <el-select
                  v-model="queryParams.deliverId"
                  filterable
                  remote
                  reserve-keyword
                  placeholder="请输入快递公司名称"
                  :remote-method="onGetDeliverList"
                  :loading="isLoadingDeliverList"
                >
                    <el-option
                      v-for="item in deliverList"
                      :key="item.delivery_id"
                      :label="item.delivery_name"
                      :value="item.delivery_id">
                    </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="备注" prop="poleCode">
                <el-input v-model="queryParams.poleCode" @keyup.enter.native="handleQuery" :clearable="true" placeholder="请输入"/>
              </el-form-item>

            </el-form>

            <el-input class="form-textarea" v-model="queryParams.poleCode" type="textarea" resize="none" rows="4" @keyup.enter.native="handleQuery" :clearable="true" placeholder="请输入单号，逗号分隔，系统自动去重"/>
            <div class="lz-margin-bottom-0 lz-margin-left-18 btn-group">
              <el-button size="small" type="primary" class="btn" @click="handleQuery">查询</el-button>
            </div>
        </div>

        <div class="table-container mt-20" v-if="dataList.length > 0">
          <el-table 
              v-loading="loading" 
              :data="dataList" 
              @select="handleSelect" 
              :height="`calc(100vh - 458px)`"
          >
            <el-table-column type="selection" width="55" />
            <el-table-column label="单号" prop="delivery_id" />
            <el-table-column label="轨迹数量" prop="like_num">
              <template slot-scope="scope">
                {{ scope.row.like_num ? scope.row.like_num : '-' }}
              </template>
            </el-table-column>
            <el-table-column label="最新状态" prop="delivery_status">
              <template slot-scope="scope">
                {{ scope.row.delivery_status ? scope.row.delivery_status : '-' }}
              </template>
            </el-table-column>
            <el-table-column label="最新时间" prop="orgName">
              <template slot-scope="scope">
                {{ scope.row.orgName ? scope.row.orgName : '-' }}
              </template>
            </el-table-column>
            <el-table-column label="最新城市" prop="poleCode">
              <template slot-scope="scope">
                {{ scope.row.poleCode ? scope.row.poleCode : '-' }}
              </template>
            </el-table-column>
            <el-table-column label="最新轨迹" prop="systemCode">
              <template slot-scope="scope">
                {{ scope.row.systemCode ? scope.row.systemCode : '-' }}
              </template>
            </el-table-column>
            <el-table-column label="正在派送" prop="status">
              <template slot-scope="scope">
                {{ getLabelInfoByValue(scope.row.status, 'deviceStatus').label }}
              </template>
            </el-table-column>
          </el-table>
        </div>
    </div>
  </template>
  <!--vue -->
  <script>
  import { getDeliveryCompanyList, getDeliveryHistory } from "@/api/group/base";
  import { 
    getUserButtons, getAllButtons, getUserTabs, getAllTabs, getUserFields, getAllFields, switchTabConfig, switchBtnConfig
  } from '@/api/group/searchTask';
  let timer;
  export default {
    components: { 
      
    },
    dicts: [],
    data() {
      return {
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          historyStr: '',
          type: "",
        },
        isLoadingDeliverList: false,
        isShowSearch: false,
        deliverList: [],
        searchFullHeight: 0,
        selectedList: [],

        userBtnList: [],
        userTabList: [],
        //tab
        activeTabName: '',
        //表格
        loading: false,
        dataList: [],
        currentSearchHeight: 52,
        //按钮设置弹窗
        isShowBtnSettingDialog: false,
        totalBtnList: [],
        //标签设置弹窗
        isShowTabSettingDialog: false,
        totalTabList: [],
      };
    },
    //生命周期函数
    mounted() {
        // this.getList();
    },
    created() {
    },
    methods: {
      //获取快递公司列表
      onGetDeliverList(value) {
        getDeliveryCompanyList({
          page: 1,
          limit: 100,
          keyword: value
        }).then(res => {
          this.deliverList = res?.data;
        })
      },
      // 选中设置删除按钮状态
      handleSelect(selection, rows) {
        this.selectedList = selection;
      },
      /** 新增按钮操作 */
      handleAdd() {
        
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      handleRefresh() {
        this.queryParams = {
          pageNum: 1,
          pageSize: 10,
          code: '',
          type: "",
          status: [],
          orgId: '',
          name: "",
          orgName: ''
        };
        this.getList();
      },
      /** 查询任务列表 */
      getList() {
        this.loading = true;
        getDeliveryHistory(this.queryParams).then(res => {
          this.selectedList = [];
          this.loading = false;
          this.dataList = res?.data;
          // this.total = res?.data?.total;
        })
      },
    }
  };
  </script>
